package io.cloud.tec.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
@Slf4j
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolTaskExecutor poolTaskExecutor() {
        log.info("初始化ThreadPoolTaskExecutor");
        ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
        threadPoolTaskExecutor.setCorePoolSize(2);
        threadPoolTaskExecutor.setMaxPoolSize(10);
        threadPoolTaskExecutor.setQueueCapacity(1000);
//        ThreadPoolTaskExecutor 实现了InitializingBean，在创建bean时，会自动调用，手动使用ThreadPoolTaskExecutor，需要手动调用initialize
//        threadPoolTaskExecutor.initialize();
        return threadPoolTaskExecutor;
    }

}
